package com.hb.webservice;

import com.hb.domain.Spitter;
import com.hb.domain.Spittle;
import com.hb.service.SpitterService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.jws.WebMethod;
import javax.jws.WebService;
import java.util.List;

/**
 * 我们注意到 SpitterServiceEndpoint 的新实现不再继承 SpringBeanAutowiringSupport 了。它完全就是一个 Spring bean，因此 SpitterServiceEndpoint
 * 不需要继承任何特殊的支持类就可以实现自动装配。
 */
@Component
@WebService(serviceName = "SpitterService")
public class NewSpitterServiceEndpoint {
    @Autowired
    private SpitterService spitterService;

    @WebMethod
    public void addSpittle(Spittle spittle) {
        spitterService.saveSpittle(spittle);
    }

    @WebMethod
    public List<Spittle> getRecentSpittles(int spittleCount) {
        return spitterService.getRecentSpittles(spittleCount);
    }

    @WebMethod
    public List<Spittle> getSpittlesForSpitter(Spitter spitter) {
        return spitterService.getSpittlesForSpitter(spitter);
    }
}
